`
https://leetcode.cn/problems/intersection-of-two-linked-lists/
`

/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} headA
 * @param {ListNode} headB
 * @return {ListNode}
 */
var getIntersectionNode = function (headA, headB) {
  // 指针遍历完链表A后，再遍历链表B，指针遍历完链表B后，再遍历链表A
  let A = headA
  let B = headB
  while (A !== B) {
    A = A ? A.next : headB
    B = B ? B.next : headA
  }
  return A
};